package com.lcredu.spring;

import com.lcredu.spring.aop.SmartAnimal;
import com.lcredu.spring.component.UserAction;
import com.lcredu.spring.component.UserDao;
import com.lcredu.spring.component.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 黎长容
 * @date 2025-07-15 22:24
 */
public class AppMain {
    public static void main(String[] args) {
        ApplicationContext ioc = new ClassPathXmlApplicationContext("beans.xml");
        UserAction userAction = (UserAction) ioc.getBean("userAction");
        UserAction userAction2 = (UserAction) ioc.getBean("userAction");

        System.out.println("userAction=" + userAction);
        System.out.println("userAction2=" + userAction2);

        UserService userService = (UserService) ioc.getBean("userService");
        System.out.println("userService=" + userService);

        UserDao userDao = (UserDao) ioc.getBean("userDao");
        System.out.println("userDao=" + userDao);

        userService.m1();

        //测试aop
        SmartAnimal smartAnimal = ioc.getBean(SmartAnimal.class);
        smartAnimal.getSum(10, 3);
    }
}
